package controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.MessageDAO;
import model.UserDAO;
import beans.MessageBean;
import beans.UserBean;

@WebServlet("/ReplyServlet")
public class ReplyServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;


	public ReplyServlet() {
		super();
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		String replyTo = request.getParameter("reply");
		String visiting = request.getParameter("to");
		UserBean visitingU = new UserBean();
		visitingU.setEmail(visiting);
		UserBean visitingUser = UserDAO.visit(visitingU);
		int replyToID = Integer.parseInt(replyTo);
		session.setAttribute("replyTo", replyToID);
		session.setAttribute("visitingUser", visitingUser);
		response.sendRedirect("sendmessage.jsp");
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

}
